#include <QtCore/QCoreApplication>
#include <iostream>

using namespace std;

enum CoffeeSize { Large, Medium, Small };

struct CoffeeMaker {

    // Coffee sizes
    static const int SmallCupVolume = 30;
    static const int MediumCupVolume = 50;
    static const int LargeCupVolume = 100;

    // Machine parameters
    static const int WaterTankVolume = 1000;
    static const int CoffeeBeanVolume = 500;
    static const int ShitContainerVolume = 500;

    static const int WaterWarningLevel = LargeCupVolume;

    // Variable members
    int water;
    int beans;
    int shit;

    // This is our brand new Coffee Maker, yeah! In capitals!
    CoffeeMaker() {
        water = 0;
        beans = 0;
        shit = 0;
    }

    int fillWaterTank(int amount) {

        if (water += amount > CoffeeMaker::WaterTankVolume) {
            water = CoffeeMaker::WaterTankVolume;
        };

        return water;
    }

    int fillBeansContainer(int amount) {
        if (beans += amount > CoffeeMaker::CoffeeBeanVolume) {
            beans = CoffeeMaker::CoffeeBeanVolume;
        }

        return beans;
    }

    int removeShit() {
        return shit = 0;
    }

    int makeCoffee(CoffeeSize size) {\

        int oldWater = this->water;

        switch (size) {
        case Medium:
            water -= MediumCupVolume;
            break;
        case Large:
            water -= LargeCupVolume;
            break;
        case Small:
            water -= SmallCupVolume;
            break;
        default:
            // unknown cup size
            cerr << "Unknown size" << endl;

        };

        if (water < 0) {
            water = oldWater;
            return 1;   // cannot make requested size, not enough water
        } else {
            int oldBeans = beans;
            int oldShit = shit;
            beans -= 20;
            shit += 20;
            if ( beans < 0 || shit > CoffeeMaker::ShitContainerVolume) {
                beans = oldBeans;
                shit = oldShit;
                return 2;   // cannot make coffee, not enough beans or too much shit
            }

            return 0;
        }
    }
};

int main(int argc, char *argv[])
{
//    QCoreApplication a(argc, argv);

    CoffeeMaker coffeeMaker;
    char input;

    cout << "Beans: " << coffeeMaker.beans << endl << \
            "Water: " << coffeeMaker.water << endl <<
            "Shit: " << coffeeMaker.shit << endl;

    cin >> input;

    return 0;

//    return a.exec();
}
